<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <!-- 
    1.一个重要的内置关系：VueComponent.prototype.__proto__ === Vue.prototype
    2.为什么要有这个关系：让组件实例对象（vc）可以访问到Vue原型上的属性、方法
   -->
  <div id="root">
    <school></school>
  </div>
</body>

<script>
  Vue.config.productionTip = false
  Vue.prototype.x = 99
  const school = Vue.extend(
    {
      name: 'school',
      template: `
    <div>
      <h2>学校名称：{{name}}</h2>
      <h2>学校地址：{{address}}</h2>
      <button @click="showX">showX</button>
    </div>
    `,
      data() {
        return {
          name: 'gzhu',
          address: 'gz'
        }
      },
      methods: {
        showX() {
          console.log(this.x)
        }
      },
    }
  )

  new Vue({
    el: '#root',
    data: {
      msg:'Hello'
    },
    components:{
      school
    }
  })

  console.log(school.prototype.__proto__ == Vue.prototype)

  // function Demo() {
  //   this.a = 1
  //   this.b = 2
  // }

  // const d = new Demo()

  // console.log(Demo.prototype) // 显示原型属性

  // console.log(d.__proto__)

  // Demo.prototype.x = 99

  // console.log(d.__proto__.x)


</script>

</html>